﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_2006_CountKDifference
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 1,2,2,1 };
            Console.WriteLine(CountKDifference(nums,1));

            Console.ReadKey();
        }
        public static int CountKDifference(int[] nums, int k)
        {
            int count = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                for (int j = i+1; j < nums.Length; j++)
                {
                    if (Math.Abs(nums[j] - nums[i])==k)
                    {
                        count++;
                    }
                }
            }
            return count;
        }
    }
  
}
